package com.atguigu.daijia.driver.controller;

import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.driver.service.DriverInfoService;
import com.atguigu.daijia.model.entity.driver.DriverSet;
import com.atguigu.daijia.model.form.driver.DriverFaceModelForm;
import com.atguigu.daijia.model.form.driver.UpdateDriverAuthInfoForm;
import com.atguigu.daijia.model.vo.driver.DriverAuthInfoVo;
import com.atguigu.daijia.model.vo.driver.DriverInfoVo;
import com.atguigu.daijia.model.vo.driver.DriverLoginVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "司机API接口管理")
@RestController
@RequestMapping(value="/driver/info")
@SuppressWarnings({"unchecked", "rawtypes"})
public class DriverInfoController {

    @Autowired
    private DriverInfoService driverInfoService;

    @Operation(summary = "小程序授权登录")
    @GetMapping("/login/{code}")
    public Result<Long> login(@PathVariable("code") String code){
        return Result.ok(driverInfoService.login(code));
    }

    @Operation(summary = "获取司机信息")
    @GetMapping("/getDriverLoginInfo/{driverId}")
    public Result<DriverLoginVo> getDriverLoginInfo(@PathVariable("driverId") Long driverId) {
        return Result.ok(driverInfoService.getDriverLoginInfo(driverId));
    }


    @Operation(summary = "获取司机认证信息")
    @GetMapping("/getDriverAuthInfo/{driverId}")
    public Result<DriverAuthInfoVo> getDriverAuthInfo(@PathVariable("driverId") Long driverId){
        return Result.ok(driverInfoService.getDriverAuthInfo(driverId));
    }

    @Operation(summary = "修改司机认证信息")
    @PostMapping("/getDriverAuthInfo")
    public Result<Boolean> UpdateDriverAuthInfoForm(@RequestBody UpdateDriverAuthInfoForm updateDriverAuthInfoForm){
        return Result.ok(driverInfoService.UpdateDriverAuthInfoForm(updateDriverAuthInfoForm));
    }


    @Operation(summary = "创建司机人脸模型")
    @PostMapping("/creatDriverFaceModel")
    public Result<Boolean> creatDriverFaceModel(@RequestBody DriverFaceModelForm driverFaceModelForm) {
        return Result.ok(driverInfoService.creatDriverFaceModel(driverFaceModelForm));
    }

    @Operation(summary = "获取司机的设置信息")
    @PostMapping("/getDriverSet/{driverId}")
    public Result<DriverSet> getDriverSet(@PathVariable("driverId") Long driverId) {
        return Result.ok(driverInfoService.getDriverSet(driverId));
    }

    @Operation(summary = "查询司机当前是否已经做了人脸识别")
    @PostMapping("/isFaceRecognition/{driverId}")
    public Result<Boolean> isFaceRecognition(@PathVariable("driverId") Long driverId) {
        return Result.ok(driverInfoService.isFaceRecognition(driverId));
    }

    @Operation(summary = "验证司机人脸")
    @PostMapping("/verifyDriverFace")
    public Result<Boolean> verifyDriverFace(@RequestBody DriverFaceModelForm driverFaceModelForm){
        return Result.ok(driverInfoService.verifyDriverFace(driverFaceModelForm));
    }


    @Operation(summary = "更新司机接单状态")
    @PostMapping("/updateServiceStatus/{driverId}/{status}")
    public Result<Boolean> updateServiceStatus(@PathVariable Long driverId,@PathVariable Integer status){
        return Result.ok(driverInfoService.updateServiceStatus(driverId,status));
    }

    @Operation(summary = "获取司机信息")
    @PostMapping("/driver/info/getDriverInfo/{driverId}/")
    public Result<DriverInfoVo> getDriverInfo(@PathVariable Long driverId){
        return Result.ok(driverInfoService.getDriverInfo(driverId));
    }
















}

